﻿using Ldt.DataEngine.DataFlowParse.Model;
using LdtDataEngin.ModuleDetail.BaseModule;
using LdtJudge.DataEngine.DataBaseStores;
using System.Diagnostics;
using System.Linq;
using System.Xml;

namespace LdtDataEngin.ModuleDetail.PersonDialogExtr
{
    /// <summary>
    /// 人员对话提取模块
    /// 输入信息:1.实体信息与实体角色信息===>DataContext.DyData_Analysis.Anjianshiti与Anjianshitijuese
    ///          2.人员对话提取的配置信息===>DataContext.DataLayerSysStores
    /// 输出信息:将人员对话息保存到了DataContext.DataLayerAns.Fayanrenduanluoxinxis
    /// </summary>
    public class PersonDialogExtrAction:AssermBase
    {
        // 上下文
        private DataContext _dataContext;

        public PersonDialogExtrAction(DataContext dataContextIn,string moudleName)
        {
            _dataContext = dataContext = dataContextIn;
            base.MoudleName = moudleName;  
        }

        /// <summary>
        /// 开始提取
        /// </summary>
        /// <param name="Name">模块名称</param>
        public void Extrat()
        {
            ConfigModel currentModelConfig = _dataContext.DataLayerSys.GetConfigModel(MoudleName);
            if (currentModelConfig != null && currentModelConfig.ConfigDetail != null)
            {
                //speakerextract
                ConfigModel SpeakerTalkConfig = currentModelConfig.ConfigDetail.FirstOrDefault(x => x.Code.ToLower() == "speakertalkextract");
                if (SpeakerTalkConfig.ExecuteType == "reg")
                {
                    ExeConfig(SpeakerTalkConfig, MoudleName);
                }
                else if (SpeakerTalkConfig.ExecuteType == "dll")
                {
                    // dll类型的执行
                    //IDLLInterface dllElement = new ElementExtractionTexTDLL() { dataLayerStores = dataLayerStores, InteractiveShow = InteractiveShow };
                    //dllElement.Extract(dataLayerStores, configState.executefile, this.ModelName);
                }
                else if (SpeakerTalkConfig.ExecuteType == "xml")
                {
                    //配置XML的为要素分析
                    IXmlInterface xmlElement = new PersonDialogExtrXml(_dataContext);
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.LoadXml(currentModelConfig.ConfigContent);
                    xmlElement.Extract(SpeakerTalkConfig, MoudleName, xmlDocument);
                }
            }
        }
    }
}
